<template>
  <div>
    <a-button @click="num = num + 1">点我{{ num }}</a-button>
    <a-button @click="num2 = num2 + 1">点我{{ num2 }}</a-button>
  </div>
</template>

<script setup lang="ts">
import { ref, watchEffect } from "vue";

const num = ref(0);
const num2 = ref(0);
const pntNum = () => {
  console.log((num.value = num.value + 1));
};

watchEffect(() => {
  console.log("执行了watchEffect", num.value);
  pntNum();
});

const pntNum2 = () => {
  setTimeout(() => {
    console.log((num2.value = num2.value + 1));
  }, 2000);
};

watchEffect(() => {
  // console.log("num2.value", num2.value);
  pntNum2();
});
</script>
